Skip to content

fix: wire up opportunity details save and fix UTC time round-trip bug#418

Open
nadavosa wants to merge 26 commits intodevelopfrom
fix/pr-409-bugs
Open

fix: wire up opportunity details save and fix UTC time round-trip bug#418
nadavosa wants to merge 26 commits intodevelopfrom
fix/pr-409-bugs

Conversation

@nadavosa
Copy link
Copy Markdown
Collaborator

Summary

Related issues / PRs

Notes

eventDate and eventTime (shown for EVENTS-type opportunities) are not included in the save payload — there is no corresponding field in ApiOpportunityPatch and the display component already shows for those fields. This needs a BE change to support.

Test plan

  • Open an opportunity profile, edit description/languages/activities/skills/numberOfVolunteers and save — changes persist after reload
  • Edit in German locale — languages save correctly (not dropped)
  • Open an accompanying opportunity — appointment time shows in local timezone in display mode
  • Edit accompanying details, save without changing the time — time does not drift on re-open

🤖 Generated with Claude Code

@lourooo
Copy link
Copy Markdown
Contributor

lourooo commented Apr 28, 2026

Good fixes overall, the UTC time separation and the language reverse mapping bug are both real issues and the solutions look correct. The new hook follows the same pattern as the rest of the codebase, no issues there.

Two small things worth checking: eventDate and eventTime are editable in the form but won't be persisted pending backend support, worth making them read-only/disabled in edit mode to avoid silent data loss. Also, does the new hook include title in its payload? If so, the existing useUpdateOpportunityTitle call might end up firing a redundant second PATCH when the title changes.

@Cy-fox
Copy link
Copy Markdown
Collaborator

Cy-fox commented Apr 28, 2026

One tiny edge-case I spotted in the time display: formatTimeForDisplay builds the conversion date using new Date() (today). If an appointment is months from now in a different DST period, the local time could be off by an hour. Super easy fix, just pass in the actual appointmentDate from the details and use that as the base. It’ll make the conversion rock-solid without touching the rest of the logic.

@arturasmckwcz
Copy link
Copy Markdown
Collaborator

eventDate and eventTime are editable in the form but won't be persisted pending backend support
@lourooo
hey Rodrigo to which API endpoint and what body is sent for writing?

@lourooo
Copy link
Copy Markdown
Contributor

lourooo commented Apr 30, 2026

It's the same PATCH /api/opportunity/:id endpoint already used by useUpdateOpportunityDetails. The SDK type ApiOpportunityPatch already has the accompanyingDetails field for it:

accompanyingDetails: {
appointmentDate?: string;
appointmentTime?: string;
// ...
}

So the fix would just be adding accompanyingDetails to the updateOpportunityDetails call in onSubmit:

accompanyingDetails: isEventType ? undefined : {
appointmentDate: values.eventDate,
appointmentTime: values.eventTime,
},

Cy-fox and others added 26 commits April 30, 2026 11:33
District field in the Refugee Accommodation Centre edit form was a
plain text input, making it impossible to consistently pick a valid
district. Replaced with a radio-list dropdown fed from the districts
API. Submission now sends the district ID instead of a raw string.

Closes #357
Fix: No ZIP/PLZ-code for Accompanying details #344
Fix: helpers.ts
… UTC

datetime-local input values are local time strings. Wrapping them in
new Date().toISOString() converts to UTC, causing appointment times to
display 2 hours early for UTC+2 users (CEST). Passing the value directly
matches how onetime_date_time is handled in the same file.

Closes #393

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Language purpose (GENERAL/TRANSLATION) was stripped from the form
data during submission, causing saved languages to lose their purpose
field. New languages default to GENERAL purpose.

Closes #367
Fix: Accompanying details: add new row #386
Fix: bugs
- Adds useUpdateOpportunityDetails hook and wires it into OpportunityDetailsEdit
  so saving the form actually PATCHes the API (fixes #401)
- Fixes toLangOptionItems to reverse the languagesToFormValues translation lookup,
  so languages initialised from the API in any locale still match on submit
- Adds formatTimeForDisplay (UTC→local) separate from parseTime (form state),
  so AccompanyingDetailsDisplay shows local time without corrupting the value
  on each save (parseTime kept raw for form state)
- Fixes formatAccompanyingDate UTC conversion to use explicit getHours/getMinutes
  instead of toTimeString() which is implementation-defined
- Removes unused formatAccompanyingDate dead code added in the same diff

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… fields in getInitialFormValues

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…n utils

Replaces the local formatTimeForDisplay implementation with a thin wrapper
around the shared utcHhmmToLocal function exported from utils/index.ts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@need4deed need4deed self-requested a review April 30, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opportunity profile: edited information in opportunity details is not saved

5 participants